﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Code;
using System.Data;

namespace E2_WEBSITE.Code.SOUNDCARD
{
    public class SoundCardDataAccess
    {
         DataProvider m_DataProvider = DataProvider.GlobalDataProvider;

        public List<string> GetListProductbyManufactureName(string sManufacture)
        {
            List<string> lstPro = new List<string>();
            string sSql = "select distinct TENSANPHAM from SOUND_CARD,SAN_PHAM,NHA_SAN_XUAT where SAN_PHAM.idNSX = NHA_SAN_XUAT.id AND NHA_SAN_XUAT.TenNSX = '" + sManufacture
           + "' AND SAN_PHAM.id=SOUND_CARD.id";

            DataTable dt = m_DataProvider.ExecuteQueryDataTable(sSql);
            if (dt != null)
            {
                int iCount = dt.Rows.Count;
                for (int i = 0; i < iCount; i++)
                {
                    lstPro.Add(dt.Rows[i][0].ToString());
                }
            }
            return lstPro;
        }

        public int GetSOUNDCARDIDByManufactureNameAndProName(string sManufactureName, string sProductName)
        {
            int iID = -1;
            string sSql = "select distinct SAN_PHAM.id from SOUND_CARD,SAN_PHAM,NHA_SAN_XUAT where SAN_PHAM.idNSX = NHA_SAN_XUAT.id AND NHA_SAN_XUAT.TenNSX = '" + sManufactureName
           + "'AND TENSANPHAM ='" + sProductName + "' AND SAN_PHAM.id=SOUND_CARD.id";

            DataTable dt = m_DataProvider.ExecuteQueryDataTable(sSql);
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    iID = int.Parse(dt.Rows[0][0].ToString());
                }
            }
            return iID;
        }
    }
    
}
